import axios from "./axios.ts";

export const getRecommend = (page: number = 0) =>
  axios.get(`/home/recommended/${page}/10`);

export const getCookbook = (id: number) => axios.get(`/recipe/detail/${id}`);

export const getCookbookInfo = (id: number) =>
  axios.get(`/recipe/relatedinfo/${id}`);

export const getSearchHot = () => axios.get(`/recipe/search/hot`);

export const getSearchSuggests = (kw: string) =>
  axios.get(`recipe/search/suggests?kw=${kw}`);

export const getSearch = (obj: object) =>
  axios.get(
    `recipe/search?keyword=${obj.value.keyword}&order=${obj.value.order}&type=${
      obj.value.type
    }&secondary_keyword=${obj.value.secondary_keyword || ""}&offset=${
      obj.value.offset
    }&limit=${obj.value.limit}`
  );

export const getUser = (id: string) => axios.get(`/user/info/${id}`);

export const getUserCookbook = (obj: object) =>
  axios.get(
    `/user/urecipes/${obj.value.id}/${obj.value.offset}/${obj.value.limit}`
  );

export const getUserFavorites = (obj: object) =>
  axios.get(
    `/user/ufavorites/${obj.value.id}/${obj.value.offset}/${obj.value.limit}`
  );

export const getUserNote = (obj: object) =>
  axios.get(
    `/user/usernotescalendar/${obj.value.id}/${obj.value.offset}/${obj.value.limit}`
  );

export const getUserCalendar = (obj: object) =>
  axios.get(
    `/user/notescalendar/${obj.value.id}/${obj.value.year}/${obj.value.month}`
  );

export const getHomeNote = (offset: number = 0) =>
  axios.get(`/home/notes/${offset}/20`);

export const getNote = (id: number) => axios.get(`/note/detail/${id}`);

export const getNoteDetail = (id: number) =>
  axios.get(`/note/related/${id}/0/20`);

export const getClassification = () => axios.get(`/recipe/flatcatalogs`);
